]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Port PanelMenu to new class framework
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 20 Nov 2011 14:38:48 +0000 (15:38 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 24 Nov 2011 08:50:04 +0000 (09:50 +0100)
Second patch in the class framework, now it's the turn of
PanelMenu (buttons, menus and status indicators).

https://bugzilla.gnome.org/show_bug.cgi?id=664436

js/gdm/powerMenu.js
js/ui/dateMenu.js
js/ui/panel.js
js/ui/panelMenu.js
js/ui/status/accessibility.js
js/ui/status/bluetooth.js
js/ui/status/keyboard.js
js/ui/status/network.js
js/ui/status/power.js
js/ui/status/volume.js
js/ui/userMenu.js

index b590d75d93871f07660080fae47b5ff621bd85da..efe1a8f93c65e7941ae90ccc029865a73cc8642a 100644 (file)
@@ -25,15 +25,12 @@ const ConsoleKit = imports.gdm.consoleKit;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 
-function PowerMenuButton() {
-    this._init();
-}
-
-PowerMenuButton.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const PowerMenuButton = new Lang.Class({
+    Name: 'PowerMenuButton',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'system-shutdown', null);
+        this.parent('system-shutdown', null);
         this._consoleKitManager = new ConsoleKit.ConsoleKitManager();
         this._upClient = new UPowerGlib.Client();
 
@@ -143,4 +140,4 @@ PowerMenuButton.prototype = {
         if (this._haveShutdown)
             this._consoleKitManager.StopRemote();
     }
-};
+});
index 224d2bcec6d59b9252ba7bb9d8349cb778f15a06..d3b2309cb09416920aad7b8b77d31eaa1cda2478 100644 (file)
@@ -40,12 +40,9 @@ function _onVertSepRepaint (area)
     cr.stroke();
 };
 
-function DateMenuButton() {
-    this._init.apply(this, arguments);
-}
-
-DateMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const DateMenuButton = new Lang.Class({
+    Name: 'DateMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function(params) {
         params = Params.parse(params, { showEvents: true });
@@ -57,7 +54,7 @@ DateMenuButton.prototype = {
         let menuAlignment = 0.25;
         if (St.Widget.get_default_direction() == St.TextDirection.RTL)
             menuAlignment = 1.0 - menuAlignment;
-        PanelMenu.Button.prototype._init.call(this, menuAlignment);
+        this.parent(menuAlignment);
 
         this._clock = new St.Label();
         this.actor.add_actor(this._clock);
@@ -239,4 +236,4 @@ DateMenuButton.prototype = {
             }
         }
     }
-};
+});
index 2f78db9666b24840a1cb25694f2f6045176bac9a..db5377611e038f512f2c47a35be0161e6c2eb312 100644 (file)
@@ -235,15 +235,12 @@ TextShadower.prototype = {
  * this menu also handles startup notification for it.  So when we
  * have an active startup notification, we switch modes to display that.
  */
-function AppMenuButton() {
-    this._init();
-}
-
-AppMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const AppMenuButton = new Lang.Class({
+    Name: 'AppMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
         this._startingApps = [];
 
         this._targetApp = null;
@@ -546,22 +543,19 @@ AppMenuButton.prototype = {
 
         this.emit('changed');
     }
-};
+});
 
 Signals.addSignalMethods(AppMenuButton.prototype);
 
 // Activities button. Because everything else in the top bar is a
 // PanelMenu.Button, it simplifies some things to make this be one too.
 // We just hack it up to not actually have a menu attached to it.
-function ActivitiesButton() {
-    this._init.apply(this, arguments);
-}
-
-ActivitiesButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const ActivitiesButton = new Lang.Class({
+    Name: 'ActivitiesButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
 
         let container = new Shell.GenericContainer();
         container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@@ -698,7 +692,7 @@ ActivitiesButton.prototype = {
         Mainloop.source_remove(this._xdndTimeOut);
         this._xdndTimeOut = 0;
     }
-};
+})
 
 function PanelCorner(panel, side) {
     this._init(panel, side);
index 1f7b87ed0dc6e00c1afd5441efa72ae7acb15126..927311b0e735116d5144075e687c3edc5b61e8f5 100644 (file)
@@ -11,11 +11,9 @@ const Main = imports.ui.main;
 const Params = imports.misc.params;
 const PopupMenu = imports.ui.popupMenu;
 
-function ButtonBox(params) {
-    this._init.apply(this, arguments);
-};
+const ButtonBox = new Lang.Class({
+    Name: 'ButtonBox',
 
-ButtonBox.prototype = {
     _init: function(params) {
         params = Params.parse(params, { style_class: 'panel-button' }, true);
         this.actor = new Shell.GenericContainer(params);
@@ -92,19 +90,16 @@ ButtonBox.prototype = {
 
         child.allocate(childBox, flags);
     },
-}
+});
 
-function Button(menuAlignment) {
-    this._init(menuAlignment);
-}
-
-Button.prototype = {
-    __proto__: ButtonBox.prototype,
+const Button = new Lang.Class({
+    Name: 'PanelMenuButton',
+    Extends: ButtonBox,
 
     _init: function(menuAlignment) {
-        ButtonBox.prototype._init.call(this, { reactive: true,
-                                               can_focus: true,
-                                               track_hover: true });
+        this.parent({ reactive: true,
+                      can_focus: true,
+                      track_hover: true });
 
         this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
         this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
@@ -175,7 +170,7 @@ Button.prototype = {
 
         this.emit('destroy');
     }
-};
+});
 Signals.addSignalMethods(Button.prototype);
 
 /* SystemStatusButton:
@@ -184,15 +179,13 @@ Signals.addSignalMethods(Button.prototype);
  * volume, bluetooth...), which is just a PanelMenuButton with an
  * icon and a tooltip
  */
-function SystemStatusButton() {
-    this._init.apply(this, arguments);
-}
-
-SystemStatusButton.prototype = {
-    __proto__: Button.prototype,
+const SystemStatusButton = new Lang.Class({
+    Name: 'SystemStatusButton',
+    Extends: Button,
 
     _init: function(iconName,tooltipText) {
-        Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
+
         this._iconActor = new St.Icon({ icon_name: iconName,
                                         icon_type: St.IconType.SYMBOLIC,
                                         style_class: 'system-status-icon' });
@@ -219,4 +212,4 @@ SystemStatusButton.prototype = {
             this.tooltip = null;
         }
     }
-};
+});
index 77c5141ba40435a64acc900a6c1ccab58719b5f6..2804da3f10bfa8147153ca4e024a25087b676812 100644 (file)
@@ -40,15 +40,12 @@ const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
 
 const HIGH_CONTRAST_THEME = 'HighContrast';
 
-function ATIndicator() {
-    this._init.apply(this, arguments);
-}
-
-ATIndicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const ATIndicator = new Lang.Class({
+    Name: 'ATIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null);
+        this.parent('preferences-desktop-accessibility', null);
 
         let highContrast = this._buildHCItem();
         this.menu.addMenuItem(highContrast);
@@ -172,5 +169,4 @@ ATIndicator.prototype = {
         });
         return widget;
     }
-};
-Signals.addSignalMethods(ATIndicator.prototype);
+});
index 9118c6f605fbdfa8ea7191a2285dcb5f83786a66..13d1b4aa9a7e14f9bcaf786ca51a46f5a773ed87 100644 (file)
@@ -23,15 +23,12 @@ const ConnectionState = {
     CONNECTING: 3
 }
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'BTIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'bluetooth-disabled', null);
+        this.parent('bluetooth-disabled', null);
 
         GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
         this._applet = new GnomeBluetoothApplet.Applet();
@@ -335,7 +332,7 @@ Indicator.prototype = {
     _cancelRequest: function() {
         this._source.destroy();
     }
-}
+});
 
 function Source() {
     this._init.apply(this, arguments);
index f6f2d456ea00fb659c7765372979feeca6199fd0..cffb6086a3a019b7b43c42a57d815468ae8d71d5 100644 (file)
@@ -36,15 +36,12 @@ const LayoutMenuItem = new Lang.Class({
     }
 });
 
-function XKBIndicator() {
-    this._init.call(this);
-}
-
-XKBIndicator.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const XKBIndicator = new Lang.Class({
+    Name: 'XKBIndicator',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, St.Align.START);
+        this.parent(0.0);
 
         this._container = new Shell.GenericContainer();
         this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@@ -219,4 +216,4 @@ XKBIndicator.prototype = {
         for (let i = 0; i < this._labelActors.length; i++)
             this._labelActors[i].allocate_align_fill(box, 0.5, 0, false, false, flags);
     }
-};
+});
index 57edc9c862b3ef77b61cea3775ae97ff2d7ea92e..9fd157d672c0a010bb00a980bd4df14b5991e8c9 100644 (file)
@@ -1548,14 +1548,12 @@ NMDeviceWireless.prototype = {
     },
 };
 
-function NMApplet() {
-    this._init.apply(this, arguments);
-}
-NMApplet.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const NMApplet = new Lang.Class({
+    Name: 'NMApplet',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'network-error');
+        this.parent('network-error', null);
 
         this._client = NMClient.Client.new();
 
@@ -2121,7 +2119,7 @@ NMApplet.prototype = {
             this._mobileUpdateId = 0;
         }
     }
-};
+});
 
 function NMMessageTraySource() {
     this._init();
index 836b010894bfa059df7d2daf66f1bac709c830aa..a3932157ab3f5b0666c91d7b5dea07edb58fa367 100644 (file)
@@ -52,15 +52,13 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
 
 const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'PowerIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing');
+        this.parent('battery-missing', null);
+
         this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
 
         this._deviceItems = [ ];
@@ -163,7 +161,7 @@ Indicator.prototype = {
         this._readPrimaryDevice();
         this._readOtherDevices();
     }
-};
+});
 
 const DeviceItem = new Lang.Class({
     Name: 'DeviceItem',
index 3caa81643f34a2e223d737fd91815933f4fb38d2..fcaa069bf122361232e01cbf4d37dfecd84f58ee 100644 (file)
@@ -17,15 +17,12 @@ const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
 
 const VOLUME_NOTIFY_ID = 1;
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'VolumeIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'audio-volume-muted', null);
+        this.parent('audio-volume-muted', null);
 
         this._control = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' });
         this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));
@@ -214,4 +211,4 @@ Indicator.prototype = {
         if (property == '_output' && !this._output.is_muted)
             this.setIcon(this._volumeToIcon(this._output.volume));
     }
-};
+});
index c934020a978f3d2f39c377d312669945cd3c9c28..fdac848f57f3eae7fd851ac1cdd0e0f114097f9b 100644 (file)
@@ -414,15 +414,13 @@ const IMStatusChooserItem = new Lang.Class({
 });
 
 
-function UserMenuButton() {
-    this._init();
-}
-
-UserMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const UserMenuButton = new Lang.Class({
+    Name: 'UserMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
+
         let box = new St.BoxLayout({ name: 'panelUserMenu' });
         this.actor.add_actor(box);
 
@@ -725,4 +723,4 @@ UserMenuButton.prototype = {
             this._session.ShutdownRemote();
         }
     }
-};
+});